
import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-04-11
 * Time: 10:32
 */
//查找两个字符串a,b的最长公共子串
public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.nextLine().toLowerCase();//短得字符串
        String s2 = scanner.nextLine().toLowerCase();//长的字符串
        func(s1, s2);



    }

    public static void func(String s1, String s2) {
        LinkedList<LinkedList<Character>> ret = new LinkedList<>();
        LinkedList<Character> list = new LinkedList<>();
        for (int k = 0; k < s2.length(); k++) {
            for (int i = 0; i < s1.length(); i++) {
                for (int j = i + 1; j < s1.length(); j++) {
                    String s = s1.substring(i, j);

                    if (s1.substring(i, j).contains(s2)) {
                        for (int n = 0; n < s.length(); n++) {
                            char ch = s.charAt(n);
                            list.add(ch);
                        }

                    }

                }
            }
        }
        ret.add(list);

    }
}
